<?php

/**
*/

define('IN_ECS', true);

require('./init.php');
require_once('../includes/cls_json.php');

$nearID = $_REQUEST['nearID'];
if (is_blank($nearID)) {
	exit(0);
}

$userType = (is_blank($_REQUEST['userType']) ? 0 : $_REQUEST['userType']);

$json = new JSON;

$res = array('error' => 0);

if ($userType == 0) {
	$sql = " UPDATE " . $ecs->table('vsalesperson_login') .
		" SET customer_id = NULL, customer_token = NULL " .
		" WHERE customer_token = '$nearID' ";
} else {
	$sql = " UPDATE " . $ecs->table('vsalesperson_login') .
		" SET customer_id = NULL, customer_token = NULL " .
		" WHERE token_id = '$nearID' ";
}
$db->query($sql);

$val = $json->encode($res);

die($val);

function is_blank($value) {
	return empty($value) && !is_numeric($value);
}
?>